package com.ty.skysystem.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ty.common.utils.Query;
import com.ty.skysystem.dao.TruckTeamDao;
import com.ty.skysystem.entity.TruckTeamEntity;
import com.ty.skysystem.entity.req.TruckTeamEntityREQ;
import com.ty.skysystem.service.TruckTeamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ty.common.utils.PageUtils;

@Service("truckTeamService")
@Slf4j
public class TruckTeamServiceImpl extends ServiceImpl<TruckTeamDao, TruckTeamEntity>
    implements TruckTeamService {

  @Override
  public PageUtils queryPage(Map<String, Object> params) {
    IPage<TruckTeamEntity> page =
        this.page(
            new Query<TruckTeamEntity>().getPage(params),
            new QueryWrapper<TruckTeamEntity>()
                .select(TruckTeamEntity.class, e -> !"is_deleted".equals(e.getColumn())));

    return new PageUtils(page);
  }

  @Override
  public PageUtils selectComprehensiveTonnage(
      Integer page, Integer limit, TruckTeamEntityREQ truckTeamEntityTo) {

    IPage<TruckTeamEntity> truckTeamEntityPage =
        baseMapper.selectComprehensiveTonnage(new Page<>(page, limit), truckTeamEntityTo);

    return new PageUtils(truckTeamEntityPage);
  }
}
